package com.plian.system.wrapper.fr.procurement;

import com.plian.system.dto.fr.procurement.MaterialProcurementDTO;
import com.plian.system.entity.fr.procurement.MaterialProcurement;
import com.plian.system.mybatis.support.BaseWrapper;
import com.plian.system.vo.fr.procurement.MaterialProcurementVO;
import com.plian.system.wrapper.util.CacheWrapperUtil;
import com.plian.system.wrapper.util.WrapperUtil;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import static com.plian.system.wrapper.util.WrapperConstant.*;

/**
 * 大宗物资采购信息包装类,返回视图层所需的字段
 *
 * @author jianglei
 * @since 2019-09-26
 */
@Mapper(componentModel = SPRING, uses = {CacheWrapperUtil.class, WrapperUtil.class})
public interface MaterialProcurementWrapper extends BaseWrapper<MaterialProcurement, MaterialProcurementDTO, MaterialProcurementVO> {

	@Override
	@Mappings(value = {
			@Mapping(source = "createUser", target = "createUserName", qualifiedByName = USER_ID_TO_NAME),
			@Mapping(source = "updateUser", target = "updateUserName", qualifiedByName = USER_ID_TO_NAME),
			@Mapping(source = "approvedUser", target = "approvedUserName", qualifiedByName = USER_ID_TO_NAME),
			@Mapping(source = "fillingUnitId", target = "fillingUnitName", qualifiedByName = ORG_ID_TO_NAME),
			@Mapping(source = "procurementCompanyRankId", target = "procurementCompanyRankName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "procurementCategoryId", target = "procurementCategoryName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "procurementWayId", target = "procurementWayName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "procurementPlatformCategoryId", target = "procurementPlatformCategoryName", qualifiedByName = DICT_CODE_TO_NAME),
	})
	MaterialProcurementVO entityToVO(MaterialProcurement entity);

}
